package main
import (
	"container/list"
	"fmt"
)
func main()  {
	// 第一种声明方式 var myList list.List;
	//第二种
	myList := list.New();
	myList.PushBack("hello")
	myList.PushBack("hello2")
	myList.PushBack("hello3")
	//{{0xc0000261e0 0xc000026240 <nil> <nil>} 3}
	fmt.Println(myList)

	//在头部插入数据
	myList.PushFront("wocao")

	//在某个元素之前插入
	

	//遍历打印
	/*hello
hello2
hello3*/
	for i := myList.Front(); i != nil; i=i.Next() {
		fmt.Println(i.Value)
	}
	//反向遍历
	for i := myList.Back(); i != nil; i=i.Prev() {
		fmt.Println(i.Value)
	}

}
